import { createRouter, createWebHashHistory } from "vue-router";
import HomeView from "../views/index.vue";

const routes = [
  {
    path: "/home",
    name: "home",
    component: HomeView,
    children: [
      {
        path: "/app.homePage",
        name: "homePage",
        component: () =>
          import("../components/home/homePage.vue"),
      }, {
        path: "/app.intelligentSearch",
        name: "intelligentSearch",
        component: () =>
          import("../components/intelligentSearch/intelligentSearch.vue"),
      }, {
        path: "/app.homeWorkStatusSee",
        name: "homeWorkStatusSee",
        component: () =>
          import("../components/homeWorkStatus/homeWorkStatusSee.vue"),
      }, {
        path: "/app.homeworkDetailsSee",
        name: "homeworkDetailsSee",
        component: () =>
          import("../components/cabin/cabinTempAndStressSee.vue"),
      }, {
        path: "/app.fillHomeWorkSee",
        name: "fillHomeWorkSee",
        component: () =>
          import("../components/dailyOperation/fillHomeWorkSee.vue"),
        children: [
          {
            path: "/app.fill1",
            name: "fill1",

            component: () =>
              import("../components/dailyOperation/fill1.vue"),
          }, {
            path: "/app.fill2",
            name: "fill2",

            component: () =>
              import("../components/dailyOperation/fill2.vue"),
          }],
        redirect: "/app.fill1",

      }, {
        path: "/app.loadHomeWorkSee",
        name: "loadHomeWorkSee",
        component: () =>
          import("../components/dailyOperation/loadHomeWorkSee.vue"),
        children: [
          {
            path: "/app.load1",
            name: "load1",

            component: () =>
              import("../components/dailyOperation/load1.vue"),
          }, {
            path: "/app.load2",
            name: "load2",

            component: () =>
              import("../components/dailyOperation/load2.vue"),
          }],
        redirect: "/app.load1",
      },
      {
        path: "/app.deviceCertificateSee",
        name: "deviceCertificateSee",
        component: () =>
          import("../components/addShip/deviceCertificateSee.vue"),
      }, {
        path: "/app.deviceCertificateAddSecond",
        name: "deviceCertificateAddSecond",
        component: () =>
          import("../components/addShip/deviceCertificateAddSecond.vue"),
      }, {
        path: "/app.shipCertificateSee",
        name: "shipCertificateSee",
        component: () =>
          import("../components/addShip/shipCertificateSee.vue"),
      }, {
        path: "/app.shipCertificateSeeSecond",
        name: "shipCertificateSeeSecond",
        component: () =>
          import("../components/addShip/shipCertificateSeeSecond.vue"),
      }, {
        path: "/app.shipSocietyCertificateSee",
        name: "shipSocietyCertificateSee",
        component: () =>
          import("../components/addShip/shipSocietyCertificateSee.vue"),
      }, {
        path: "/app.shipSpecificationSee",
        name: "shipSpecificationSee",
        component: () =>
          import("../components/addShip/shipSpecificationSee.vue"),
      },
      {
        path: "/app.shipSpecificationEdit",
        name: "shipSpecificationSeeSecond",
        component: () =>
          import("../components/addShip/shipSpecificationSeeSecond.vue"),
      },
      {
        path: "/app.shipSpecificationAdd",
        name: "shipSpecificationAdd",
        component: () =>
          import("../components/addShip/shipSpecificationSeeThird.vue"),
      }, {
        path: "/app.homeWorkReportSee",
        name: "homeWorkReportSee",
        component: () =>
          import("../components/beAddShip/homeWorkReportSee.vue"),


      }, {
        path: "/app.lngShipCompanySee",
        name: "shipCompanySee",
        component: () =>
          import("../components/beAddShip/shipCompany/shipCompanySee.vue"),

      }, {
        path: "/app.anly",
        name: "anly",
        component: () =>
          import("../components/beAddShip/anly.vue"),
      }, {
        path: "/app.work",
        name: "work",
        component: () =>
          import("../components/beAddShip/work.vue"),
      }, {
        path: "/app.shipDataSee",
        name: "shipDataSee",
        component: () =>
          import("../components/beAddShip/shipDataSee.vue"),
      }, {
        path: "/app.lngShipDetailsSee",
        name: "shipTypeSee",
        component: () =>
          import("../components/beAddShip/shipClient/LNG/shipTypeSee.vue"),
      }, {
        path: "/app.userSee",
        name: "userSee",
        component: () =>
          import("../components/count/userSee.vue"),
      }, {
        path: "/app.dictDataSee",
        name: "dictDataAdd",
        component: () =>
          import("../components/count/dictDataSee.vue"),
      }, {
        path: "/app.shipDataSee",
        name: "shipDataSee",
        component: () =>
          import("../components/beAddShip/shipDataSee.vue"),
      }, {
        path: "/app.companyAddStatisticsSee",
        name: "companyAddStatisticsSee",
        component: () =>
          import("../components/cabin/companyAddStatisticsSee.vue"),
      },

      {
        path: "/app.homeworkSummarySee",
        name: "homeworkSummarySee",
        component: () =>
          import("../components/cabin/homeworkSummarySee.vue"),
      },
      {
        path: "/app.wharfHomeworkStatisticsSee",
        name: "wharfHomeworkStatisticsSee",
        component: () =>
          import("../components/cabin/wharfHomeworkStatisticsSee.vue"),
      },
      {
        path: "/app.huaihe",
        name: "huaihe",
        component: () =>
          import("../components/cabin/huaihe.vue"),
      },
      {
        path: "/app.summary",
        name: "summary",
        component: () =>
          import("../components/cabin/zong.vue"),
      },
      {
        path: "/app.test",
        name: "test",
        component: () =>
          import("../components/cabin/test.vue"),
      },
      {
        path: "/app.actualWorkTimeSee",
        name: "actualWorkTimeAdd",
        component: () =>
          import("../components/workRecord/actualTime.vue"),
      },
      {
        path: "/app.navigateAndHomeworkSee",
        name: "navigateAndHomeworkSee",
        component: () =>
          import("../components/workRecord/tripWork.vue"),
      },
      {
        path: "/app.addFillHomeWorkSee",
        name: "addfill",
        component: () =>
          import("../components/addWork/fillWork.vue"),
      },
      {
        path: "/app.addLoadHomeWorkSee",
        name: "addLoad",
        component: () =>
          import("../components/addWork/loadWork.vue"),
      },
      {
        path: "/app.fillSpecificationSee",
        name: "fillSpecificationAdd",
        component: () =>
          import("../components/addPage/fillSpecificationAdd.vue"),
      },
      {
        path: "/app.fillSpecificationAddSecond",
        name: "fillSpecificationAddSecond",
        component: () =>
          import("../components/addPage/fillSpecificationAddSecond.vue"),
      },
      {
        path: "/app.fillSpecificationAddThrid",
        name: "fillSpecificationAddThrid",
        component: () =>
          import("../components/addPage/fillSpecificationAddThrid.vue"),
      },
      {
        path: "/app.lngStandardAddThird",
        name: "lngStandardAddThird",
        component: () =>
          import("../components/addPage/lngStandardAddThird.vue"),
      },
      {
        path: "/app.otherSpecificationSee",
        name: "otherSpecificationAdd",
        component: () =>
          import("../components/addPage/otherSpecificationAdd.vue"),
      },
      {
        path: "/app.harbourSee",
        name: "haiGangWeiLaiAdd",
        component: () =>
          import("../components/addPage/navigation/haiGangWeiLaiAdd.vue"),
      }, {
        path: "/app.haiGangZhiYuanSee",
        name: "/app.haiGangZhiYuanAdd",
        component: () =>
          import("../components/addPage/navigation/haiGangZhiYuanAdd.vue"),
      }, {
        path: "/app.huaiHeSee",
        name: "huaiHeAdd",
        component: () =>
          import("../components/addPage/navigation/huaiHeAdd.vue"),
      },
      {
        path: "/app.methanalShipCompanySee",
        name: "methanalShipCompanyAdd",
        component: () =>
          import("../components/beAddShip/shipCompany/methanalShipCompanyAdd.vue"),
      },
      {
        path: "/app.dictionaryDetail",
        name: "dictionaryDetail",
        component: () =>
          import("../components/count/child/secondPage.vue"),
      },
      {
        path: "/app.methanalShipDetailsSee",
        name: "methanalShipDetailsAdd",
        component: () =>
          import("../components/beAddShip/shipClient/Mehtod/methanalShipDetailsAdd.vue"),
      }, {
        path: "/app.lngStandardSee",
        name: "lngStandardAdd",
        component: () =>
          import("../components/addPage/lngStandardAdd.vue"),
      },
      {
        path: "/app.lngStandardAddSecond",
        name: "lngStandardAddSecond",
        component: () =>
          import("../components/addPage/lngStandardAddSecond.vue"),
      },
      {
        path: "/app.addressBookSee",
        name: "addressBookSee",
        component: () =>
          import("../components/addPage/addressBookSee/addressBookSee.vue"),
      },
      {
        path: "/app.websiteSee",
        name: "websiteSee",
        component: () =>
          import("../components/addPage/websiteSee/websiteSee.vue"),
      },
    ],
    redirect: '/app.homePage'
  },

  {
    path: "/",
    name: "login",

    component: () =>
      import(/* webpackChunkName: "about" */ "../login/login.vue"),
  },
];


const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
router.beforeEach((to, from, next) => {
  //  判断是否需要登录

  if (to.path == "/login" || to.path == "/") {
    next()
  } else if (sessionStorage.getItem('token')) {

    next()
  } else {
    next({
      path: "/"
    })
  }
})

export default router;
